package com.google.qam.texture;

import android.content.Context;
import android.graphics.Bitmap;

public abstract class Texture {
	public static final int STATE_UNLOADED = 0;
    public static final int STATE_LOADED = 1;
	
    int mState = STATE_UNLOADED;
	int mId;
    int mWidth;
    int mHeight;
    float mNormalizedWidth;
    float mNormalizedHeight;
    Bitmap mBitmap;
    
    public final void clear() {
        mId = 0;
        mWidth = 0;
        mHeight = 0;
        mNormalizedWidth = 0;
        mNormalizedHeight = 0;
        if (mBitmap != null) {
            mBitmap.recycle();
            mBitmap = null;
        }
    }
    
    public final boolean isLoaded() {
        return mState == STATE_LOADED;
    }
    
    public final int getState() {
        return mState;
    }
    
    public final int getWidth() {
        return mWidth;
    }

    public final int getHeight() {
        return mHeight;
    }

    public final float getNormalizedWidth() {
        return mNormalizedWidth;
    }

    public final float getNormalizedHeight() {
        return mNormalizedHeight;
    }
    
    /** Returns a bitmap, or null if an error occurs. */
    public abstract Bitmap load(Context context);
}
